package com.qbw.app.model;

import androidx.databinding.Bindable;

import com.google.gson.Gson;
import com.qbw.app.BR;
import com.qbw.l.L;

import java.io.Serializable;
import java.util.List;

/**
 * @author QBW
 * @date 2019-09-01
 */
public class Location extends BaseModel implements Serializable {

    private String vehicleCode;
    private float altitude;
    private int drivingState;
    private long gpsTime;
    private double latitude;
    private double longitude;
    private double latitude84;
    private double longitude84;
//    private int satelliteNumber;
    private int signalSpan;
    private double speed;
    private double gpsSpeed;
    private String address;
    private String vehicleNick;
    private int mcc;
    /**
     * 这种数据有可能很大，不能使用bundle传递
     */
    private List<TravelGps> gpsDatas;
    private transient boolean inited;
    private double direction;

    public double getGpsSpeed() {
        return gpsSpeed;
    }

    public void setGpsSpeed(double gpsSpeed) {
        this.gpsSpeed = gpsSpeed;
    }

    public String getVehicleCode() {
        return vehicleCode;
    }

    public void setVehicleCode(String vehicleCode) {
        this.vehicleCode = vehicleCode;
    }

    public float getAltitude() {
        return altitude;
    }

    public void setAltitude(float altitude) {
        this.altitude = altitude;
    }

    @Bindable
    public int getDrivingState() {
        return drivingState;
    }

    public void setDrivingState(int drivingState) {
        this.drivingState = drivingState;
        notifyPropertyChanged(BR.drivingState);
    }

    @Bindable
    public long getGpsTime() {
        return gpsTime;
    }

    public void setGpsTime(long gpsTime) {
        this.gpsTime = gpsTime;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude84() {
        return latitude84;
    }

    public void setLatitude84(double latitude84) {
        this.latitude84 = latitude84;
    }

    public double getLongitude84() {
        return longitude84;
    }

    public void setLongitude84(double longitude84) {
        this.longitude84 = longitude84;
    }

//    public int getSatelliteNumber() {
//        return satelliteNumber;
//    }
//
//    public void setSatelliteNumber(int satelliteNumber) {
//        this.satelliteNumber = satelliteNumber;
//    }

    public int getSignalSpan() {
        return signalSpan;
    }

    public void setSignalSpan(int signalSpan) {
        this.signalSpan = signalSpan;
    }

    @Bindable
    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    @Bindable
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
        notifyPropertyChanged(BR.address);
    }

    public boolean isInited() {
        return inited;
    }

    public void setInited(boolean inited) {
        this.inited = inited;
    }

    @Bindable
    public String getVehicleNick() {
        return vehicleNick;
    }

    public void setVehicleNick(String vehicleNick) {
        this.vehicleNick = vehicleNick;
    }

    public boolean isGpsValid() {
        return (int) latitude != 0 && (int) longitude != 0;
    }

    public List<TravelGps> getGpsDatas() {
        return gpsDatas;
    }

    public void setGpsDatas(List<TravelGps> gpsDatas) {
        this.gpsDatas = gpsDatas;
    }

    public int getGpsDataSize() {
        return gpsDatas == null ? 0 : gpsDatas.size();
    }

    public String getGpsDatasJson() {
        if (getGpsDataSize() > 0) {
            try {
                return new Gson().toJson(gpsDatas);
            } catch (Exception e) {
                e.printStackTrace();
                L.GL.e(e);
            }
        }
        return "";
    }

    public double getDirection() {
        return direction;
    }

    public static class Response extends BaseResponse<Location> {}

    public int getMcc() {
        return mcc;
    }

    public void setMcc(int mcc) {
        this.mcc = mcc;
    }
}
